package com.example.demo.services.imp;

import com.example.demo.entity.apply;
import com.example.demo.entity.teacher;
import com.example.demo.mapper.applyMapper;
import com.example.demo.services.applyService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class applyServiceImp implements applyService {

    @Autowired
    private applyMapper applyMapper;


    @Override
    public Integer addApply(String name, LocalDateTime goTime, LocalDateTime endTime, String type, String sec, String teacher, Integer liveTime,String userId,Integer teacherId) {
        return applyMapper.addapply( name, goTime, endTime, type, sec, teacher, liveTime, userId, teacherId);
    }

    @Override
    public List<apply> selectall() {
        return applyMapper.selectall();
    }

    /**
     *
     * @param id 职工号
     * @return
     */

    @Override
    public List<apply> studentSel(Integer id) {
        return applyMapper.studentSel(id);
    }

    @Override
    public Integer teacherSelete(Integer teacher, Integer id,Integer type) {
        return applyMapper.teacherSelete(teacher, id,type);
    }

    @Override
    public List<apply> student(String id) {
        return applyMapper.student(id);
    }

    @Override
    public apply studentSelete(Integer id) {
        return applyMapper.studentSelete(id);
    }

    @Override
    public Integer countAll(Integer teacherId) {
        return applyMapper.countAll(teacherId);
    }

    @Override
    public List<teacher> selectTeacher() {
        return applyMapper.selectTeacher();
    }

    @Override
    public List<apply> students() {
        return applyMapper.guiangliyuanList();
    }

    @Override
    public PageInfo<apply> selectPage(Integer page,Integer size) {
        PageHelper.startPage(page, size);
        List<apply> list=applyMapper.selectall();
        PageInfo<apply> pageInfo=new PageInfo<apply>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<apply> chazhaoUserId(String userId,Integer page,Integer size) {
        PageHelper.startPage(page, size);
        List<apply> list=applyMapper.chazhaoUserId(userId);
        PageInfo<apply> pageInfo=new PageInfo<apply>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<apply> selectNoApply(String userId,Integer page,Integer size) {
        PageHelper.startPage(page, size);
        List<apply> list=applyMapper.selectNoApply(userId);
        PageInfo<apply> pageInfo=new PageInfo<apply>(list);
        return pageInfo;
    }

    @Override
    public Object selectAllreject(Integer size, Integer page,String userId) {
        PageHelper.startPage(page,size);
        List<apply> list=applyMapper.selectAllreject(userId);
        PageInfo<apply> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Object deleteApply(Integer id) {
        return applyMapper.deleteApply(id);
    }
}
